package com.hk.springmvc.web.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.mvc.SimpleFormController;

import com.hk.springmvc.web.modelandview.UserModel;

public class RegisterSimpleFormController extends SimpleFormController{
	public RegisterSimpleFormController(){
		setCommandClass(UserModel.class);//设置命令对象实现类
		setCommandName("user");//设置命令对象的名字
	}
	//form object表单对象，提供展示表单时的数据表单，使用commondName放入请求
	protected Object formBackingObject(){
		UserModel user = new UserModel();
		user.setUsername("请输入用户名");
		return user;
	}
	//提供展示表单时需要的一些其他数据
	protected Map referenceData(HttpServletRequest request){
		Map map = new HashMap();
		map.put("cityList", Arrays.asList("成都","上海","北京"));
		return map;
	}
	protected void doSubmitAction(Object command){
		UserModel user = (UserModel) command;
		//TODO 调用业务对象处理
		System.out.println(user);
	}
}
